package filestorage;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

public class Filestorage {

    public static void main(String[] args) throws FileNotFoundException {

        
        Scanner keyboard = new Scanner(System.in);
        File file = new File("test.txt");
        PrintWriter pw = new PrintWriter(file);
        int x=0;
        while (x>=0)
        {
        pw.println(x);
        System.out.println("input number");
        x = keyboard.nextInt();
        }
        Scanner scanFile = new Scanner(file);
        pw.close();
        x=0;
        while (scanFile.hasNextLine()) {
        String parser=scanFile.nextLine();
        x = x + Integer.parseInt(parser);
        }
        System.out.println("the sum is " + (x));
        


    
    }
    
}
